package com.ruoyi.common.yyyoupin.bean;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum BuyErrorCodeEnum {
    CODE_5201(5201, "该账户交易功能被封禁,可以联系人工客服"),
    CODE_5202(5202, "代购对象由于过去12小时赠送订单存在多次不收货或者拒绝收货行为，系统暂时限制其进行购买，该限制将在%s之后解除"),
    CODE_5212(5212, "余额不足，请确保余额充足再创单"),
    CODE_5213(5213, "此限定金额下无商品可供购买"),
    CODE_5214(5214, "暂无在售商品，请选购其他商品"),
    CODE_5301(5301, "商品状态发生变化，暂无法购买，请选购其他商品"),
    CODE_5299(5299, "无法购买"),
    CODE_5408(5408, "代购对象的交易链接格式错误");

    private final int code;
    private final String msg;

    public static String getMsgByCode(int code) {
        for (BuyErrorCodeEnum errorCodeEnum : BuyErrorCodeEnum.values()) {
            if (errorCodeEnum.getCode() == code) {
                return errorCodeEnum.getMsg();
            }
        }
        return "Invalid code"; // Or handle as needed
    }
}
